﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace QQSDK
{
    public class AnalyticsSample : SDKBaseSample
    {
       
        /// <summary>
        /// 普通打点事件，原数数事件
        /// </summary>
        public void SetThinkTrackEvent()
        {
            Dictionary<string, object> paramDict = new Dictionary<string, object>();
            paramDict.Add("test_param1", 1);
            paramDict.Add("test_param2", true);
            paramDict.Add("test_param3", "test");
            AnalyticsManager.SetThinkTrackEvent("test_thinktrack", paramDict);
        }

        #region 2023 新增事件测试
        public void LogClickEvent()
        {
            AnalyticsManager.LogClickEvent("test_click_act", null);
        }

        public void LogShowEvent()
        {
            AnalyticsManager.LogShowEvent("test_show_act", null);
        }

        public void LogTaskEvent()
        {
            ArrayList m_List = new ArrayList();
            Dictionary<string, object> m_Dt = new Dictionary<string, object>();
            m_Dt.Add("test_act1", "a");
            m_Dt.Add("test_act2", "b");
            m_Dt.Add("test_act", 1);
            m_List.Add(m_Dt);
            AnalyticsManager.LogTaskEvent("test_task_act", m_List);
            m_Dt.Clear();
            m_List.Clear();
        }

        private string pagename = "test_one_name";

        public void LogPageViewBeginEvent()
        {
            ArrayList m_List = new ArrayList();
            Dictionary<string, object> m_Dt = new Dictionary<string, object>();
            m_Dt.Add("test_viewbegin", 1);
          
            m_List.Add(m_Dt);
            AnalyticsManager.LogPageViewBeginEvent(pagename ,m_List);
            m_Dt.Clear();
            m_List.Clear();
        }

        public void LogPageViewEndEvent()
        {
            ArrayList m_List = new ArrayList();
            Dictionary<string, object> m_Dt = new Dictionary<string, object>();
            m_Dt.Add("test_viewend", 2);

            m_List.Add(m_Dt);
            AnalyticsManager.LogPageViewEndEvent(pagename, m_List);
            m_Dt.Clear();
            m_List.Clear();
        }
        #endregion


        #region 老事件测试
        public void LogClickEventWithPage()
        {
            AnalyticsManager.LogClickEventWithPage("test_click_page", "test_click_cnt", "test_click_act", null);
        }
        public void LogTaskEventWithPage()
        {
            ArrayList m_List = new ArrayList();
            Dictionary<string, object> m_Dt = new Dictionary<string, object>();
            m_Dt.Add("test_arg1", "a");
            m_Dt.Add("test_arg2", "b");
            m_Dt.Add("test_count", 1);
            m_List.Add(m_Dt);
            AnalyticsManager.LogTaskEventWithPageNew("test_task_event_page", "test", "test", true, m_List);
            m_Dt.Clear();
            m_List.Clear();
        }
        #endregion


        #region 老事件，未测试
        public void LogPageViewBeginEventWithPage()
        {
            ArrayList m_List = new ArrayList();
            Dictionary<string, object> m_Dt = new Dictionary<string, object>();
            m_Dt.Add("test_page1", "a");
            m_Dt.Add("test_page2", 1);
            m_Dt.Add("test_page3", true);
            m_List.Add(m_Dt);
            AnalyticsManager.LogPageViewBeginEventWithPage(pagename, m_List);
            m_Dt.Clear();
            m_List.Clear();
        }
        public void LogPageViewEndEventWithPage()
        {
            AnalyticsManager.LogPageViewEndEventWithPage(pagename, null);
        }
        public void LogShowEventWithPage()
        {
            AnalyticsManager.LogShowEventWithPage("test_show_event__page", "test", "test", null);
        }

        #endregion


        #region 2023 用户属性
        public void SetThinkUser()
        {
            Dictionary<string, object> userPropertiesDict = new Dictionary<string, object>();
            userPropertiesDict.Add("test_propertie1", 2);
            userPropertiesDict.Add("test_propertie2", true);
            userPropertiesDict.Add("test_propertie3", "p3");
        
            string str = JsonMapper.ToJson(userPropertiesDict);
            userPropertiesDict.Clear();
            AnalyticsManager.SetUserProperty(str);
        }

        /// <summary>
        /// 用户属性写入，只有第一次生效 之后会忽略
        /// </summary>
        public void SetThinkUserOnce()
        {
            Dictionary<string, object> userPropertiesDict = new Dictionary<string, object>();
            userPropertiesDict.Add("test_oncep1", 1);
            userPropertiesDict.Add("test_oncep2", true);
            userPropertiesDict.Add("test_oncep3", System.DateTime.Now.ToString());
            string str = JsonMapper.ToJson(userPropertiesDict);
            userPropertiesDict.Clear();
            AnalyticsManager.SetUserProperty(str, true);
        }

        /// <summary>
        /// 用户属性累计（可为负数）
        /// </summary>
        public void SetThinkUserAdd()
        {
            Dictionary<string, object> userAddDict = new Dictionary<string, object>();
            userAddDict.Add("test_user_add", 2);
            string str = JsonMapper.ToJson(userAddDict);
            userAddDict.Clear();
            AnalyticsManager.AddUserProperty(str);
        }
        public void DeleteThinkUser()
        {
            //AnalyticsManager.DeleteThinkUser();
        }
        #endregion

    }
}